//
//  SHTitleViewLabel.swift
//  SHWeibo
//
//  Created by jingming wang on 16/8/3.
//  Copyright © 2016年 cpy.name. All rights reserved.
//

import UIKit

class SHTitleViewLabel: UILabel {
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        let name = SHUserAccountViewModel.sharedTools.userAccount?.screen_name ?? ""
        let str = "发微博\n\(name)"
        // 获取range
        let range = (str as NSString).rangeOfString(name)
        // 创建一个可变的富文本
        let attr = NSMutableAttributedString(string: str)
        // 设置富文本
        attr.addAttributes([NSForegroundColorAttributeName: K_THEME_COLOR, NSFontAttributeName: Font(12)], range: range)
        
        numberOfLines = 0
        textAlignment = .Center
        attributedText = attr
        sizeToFit()
        
        
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
